NoteCome
Contact :
mailto:peter.notenbaert@skynet.be
Contents
GenValidator is a COM Component that implements a rule based validator. It allows you to execute generic validations against your data. Through a few simple methods you are able to check whether complex rules evaluate to True or False.
GenValidator is the ideal component to use for validating all records in a database table against rules specified in a rules table. You can add, remove or edit business rules without the need of recompiling your code.
GenValidator is very fast, very easy and very cheap. Your are going to use GenValidator in all your applications once you’ve discovered its power and ease.
Microsoft ActiveX Data Objects 2.0. Download from
http://www.microsoft.com/data/mdac2.htmRegsvr32.exe
VB 6.0 Runtime library
GenValidatorInterface.dll contains the interface that is implemented by GenValidator.dll
To use the validator in VB do the following :
Dim objValidator As GenValidatorInterface.IgenValidator
Set objValidator = CreateObject("GenValidator.CValidate")
And you are ready to execute the methods of objValidator
AdoChkRule Method
Evaluates a given rule on the current record of a ado recordset. Returns true or false
Syntax
AdoChkRule(Values, Rule) As Boolean
The AdoChkRule function has these named arguments :
|
Part |
Description |
|
Values |
Required. Ado recordset object. The values that are to be checked are represented by this recordset. |
|
Rule |
Required. String expression. Represents the rule that is checked. A string made up of one or more individual clauses concatenated with AND or OR operators |
Return Values
True
False
Remarks
The Rule string is made up of clauses in the form FieldName-Operator-Value (for example, "LastName = 'Smith'"). You can create compound clauses by concatenating individual clauses with AND (for example, "LastName = 'Smith' AND FirstName = 'John'") or OR (for example, "LastName = 'Smith' OR LastName = 'Jones'"). Use the following guidelines for criteria strings:
'Smith', #8/24/95#, 12.345 or $50.00). Use single quotes with strings and pound signs (#) with dates. For numbers, you can use decimal points, dollar signs, and scientific notation. If Operator is LIKE, Value can use wildcards. Only the asterisk (*) and percent sign (%) wild cards are allowed, and they must be the last character in the string. Value cannot be Null.
(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'
(LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
LastName Like '*mit*'), or only at the end of the pattern (for example, LastName Like 'Smit*').
AdoChkTable Method
Evaluates all rules in a rules recordset for all records in a values recordset.
Syntax
AdoChkTable(Values, Rules, RuleFieldName) As ADODB.Recordset
The AdoChkRule function has these named arguments :
|
Part |
Description |
|
Values |
Required. Ado recordset object. The values that are to be checked are represented by this recordset. |
|
Rules |
Required. Ado recordset object. Represents the rules that are to be checked, together with custom additional fields. These could be error numbers, error descriptions, etc. One field of the recordset has to contain the rule string. This is a string made up of one or more individual clauses concatenated with AND or OR operators |
|
RuleFieldName |
Required. A string expression. Defines the fieldname of the field in the Rules recordset that contains the rule expression |
Return Values
Recordset. This recordset contains all the fields of Values and all the Fields of Rules. For every combination of a rule and a record that evaluates to true a record is cretaed in the returned recordset.
Remarks
The syntax of the Rule string in the rules recordset is same as for method AdoChkRule
ArrayChkRule Method
Evaluates a given rule on a array of values. Returns true or false
Syntax
AdoChkRule(Values, Rule) As Boolean
The AdoChkRule function has these named arguments :
|
Part |
Description |
|
Values |
Required. Array of type gvDataField. Each item of the array represents a fieldname with its data type and value. |
|
Rule |
Required. String expression. Represents the rule that is checked. A string made up of one or more individual clauses concatenated with AND or OR operators |
Return Values
True
False
Remarks
gvDataField is defined as :
Type gvDataField
Datatype As gvDatatype
Fieldname As String
Value As Variant
End Type
gvDatatype is an enumaration defined as : (analogue to ado datatypes, see ado help to find correct meaning)
Public Enum gvDatatype
gvBigInt = 20
gvBinary = 128
gvBoolean = 11
gvBSTR = 8
gvChapter = 136
gvChar = 129
gvCurrency = 6
gvDate = 7
gvDBDate = 133
gvDBFileTime = 137
gvDBTime = 134
gvDBTimeStamp = 135
gvDecimal = 14
gvDouble = 5
gvEmpty = 0
gvError = 10
gvFileTime = 64
gvGUID = 72
gvIDispatch = 9
gvInteger = 3
gvIUknown = 13
gvLongVarBinary = 205
gvLongVarChar = 201
gvLongVarWChar = 203
gvNumeric = 131
gvPropVariant = 138
gvSingle = 4
gvSmallInt = 2
gvTinyInt = 16
gvUnsignedBigInt = 21
gvUnsignedInt = 19
gvUnsignedSmallInt = 18
gvUnsignedTinyInt = 17
gvUserDefined = 132
gvVarBinary = 204
gvVarChar = 200
gvVariant = 12
gvVarNumeric = 139
gvVarWChar = 202
gvWChar = 130
End Enum
The syntax of the Rule string is same as for method AdoChkRule